	$(function(){
		$("#ChargeTypeTable").datagrid({
			pagination:true,
			idField:"id"
		});
	})
	//添加
		function addChargeType(){
			var d = $("<div></div>").appendTo("body");
			d.dialog({
				title:"添加收费类型",
				width:450,
				height:450,
				modal:true,
				href:"registrationChargeType/RegistrationChargeTypeForm",
				onClose:function(){$(this).dialog("destroy");},
				buttons:[{
					text:"确定",
					handler:function(){
						$("#RegistrationChargeTypeForm").form("submit",{
							url:"registrationChargeType/add",
							success:function(data){
								d.dialog("close");
								$("#ChargeTypeTable").datagrid("reload");
							}
						});
					}
				},{
					text:"取消",
					handler:function(){
						d.dialog("close");
					}
				}]
			});
		}
	//修改
	function editChargeType(){
		var row = $("#ChargeTypeTable").datagrid("getSelected");
		if(row == null){
			return;
		}
		$("#ChargeTypeTable").datagrid("clearSelections");
		$("#ChargeTypeTable").datagrid("selectRecord",row.id);
		var d = $("<div></div>").appendTo("body");
		d.dialog({
			title:"编辑",
			width:450,
			height:450,
			modal:true,
			href:"registrationChargeType/RegistrationChargeTypeForm",
			onClose:function(){$(this).dialog("destroy");},
			onLoad:function(){
				$.post("registrationChargeType/view",{id:row.id},function(data){
					$("#RegistrationChargeTypeForm").form("load",data);
				});
			},
			buttons:[{
				text:"确定",
				handler:function(){
					$("#RegistrationChargeTypeForm").form("submit",{
						url:"registrationChargeType/edit",
						success:function(data){
							d.dialog("close");
							$("#ChargeTypeTable").datagrid("reload");
						}
					});
				}
			},{
				text:"取消",
				handler:function(){
					d.dialog("close");
				}
			}]
		});
	}
	//逻辑删除
	function deleteChargeType(){
			var selRows = $("#ChargeTypeTable").datagrid("getSelections");
			if(selRows.length == 0){
				$.messager.alert("提示","请选中要删除的数据行！","warning");
				return;
			}
			$.messager.confirm("提示","确定要删除选中的数据吗？",function(r){
				if(r){
					//3. 发送异步请求，带选中行的编号
					//拼接删除条件
					var postData = "";
					$.each(selRows,function(i){
						postData += "ids="+this.id;
						if(i < selRows.length - 1){
							postData += "&";
						}
					});
				}
				$.post("registrationChargeType/deleteRegistrationChargeType",postData,function(data){
					if(data.result == true){
						//4. 删除成功后，刷新表格 reload
						$("#ChargeTypeTable").datagrid("reload");
					}
				});
			});
		}
	//条件查询
	function setCondition(){
		var postData = {typeName : $("#typeName").val()};
		$("#ChargeTypeTable").datagrid("reload",postData)
	}
	function resetCondition(){
		$("#userCondition").form("clear");
	}